//# sourceURL=http://uMapApp/Module/DataManageModule/DataManageModule
define([
    "mhjs/mhjs"
    , "uMap/uMap"
    , "uEarth/uEarth"
    , "../Module"
    , "../../UI/Panel/FloatPanel"
    , "../../UI/Panel/PanelBlock/PanelBlock"
    , "../../UI/Panel/PanelBlock/ListBlock"
    , "../../UI/Panel/Item/EquipmentListItem"
    , "../../UI/Panel/TitleMenuPanel"
    , "../../UI/Panel/CountTablePanel"
    , "../../UI/TopModuleMenu/TopModuleMenus"
    , "../../UI/TopMenu/TopMenus"
    , "../../UI/Layer"
    , "../../UI/Panel/Item/CountItem"
    , "../../UI/Panel/PanelBlock/TableBlock"
    , "../Bridge/BridgeWeatherDetectionNodeAlarmBlock"
], function (
    mhjs
    , uMap
    , uEarth
    , Module
    , FloatPanel
    , PanelBlock
    , ListBlock
    , EquipmentListItem
    , TitleMenuPanel
    , CountTablePanel
    , TopModuleMenus
    , TopMenus
    , Layer
    , CountItem
    , TableBlock
    , BridgeWeatherDetectionNodeAlarmBlock
) {

    function DataManageModule(option) {

        var _this = this;

        Module.call(_this, option);

        _this.title = "大数据驾驶舱";
        _this.icon = _this.app.icons.home;

        _this.panels = {};

        _this.layer = new Layer({
            "app": _this.app
        });

        _this.panels.bridgeEventPanel = new CountTablePanel({
            "class"     : "leftPanel top newPanel",
            "title"     : "桥下空间事件预警",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.panels.bridgeDetectionPanel = new CountTablePanel({
            "class"     : "leftPanel mid newPanel",
            "title"     : "单柱桥梁防倾覆位移监测",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.panels.cargoPanel = new CountTablePanel({
            "class"     : "leftPanel bottom newPanel",
            "title"     : "智慧仓库",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.panels.ETCPanel = new CountTablePanel({
            "class"     : "rightPanel top newPanel",
            "title"     : "智能门架防护警戒",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.panels.bridgeWeatherDetectionPanel = new CountTablePanel({
            "class"     : "rightPanel mid newPanel",
            "title"     : "桥梁气象实时监测",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.panels.weatherPanel = new CountTablePanel({
            "class"     : "rightPanel mid newPanel",
            "title"     : "道路气象设备",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.panels.roadCameraPanel = new CountTablePanel({
            "class"     : "rightPanel bottom newPanel",
            "title"     : "道路监控",
            "showMinMax": true,
            "app"       : _this.app
        });

        _this.app.ui.layout.left.append(_this.panels.cargoPanel);
        _this.app.ui.layout.left.append(_this.panels.bridgeDetectionPanel);
        _this.app.ui.layout.left.append(_this.panels.bridgeEventPanel);
        _this.app.ui.layout.right.append(_this.panels.ETCPanel);
        _this.app.ui.layout.right.append(_this.panels.bridgeWeatherDetectionPanel);
        _this.app.ui.layout.right.append(_this.panels.roadCameraPanel);
        // _this.app.ui.layout.right.append(_this.rightPanel);

        _this.app.modules.WMS.modules.workAreaCameraModule.loadInit(function () {

            _this.panels.cargoPanel.data = {
                "head"  : [
                    {
                        "label"    : "编号",
                        "autoCount": function (index) {
                            return String(index + 1000).substring(1, 4);
                        },
                        "col"      : {"width": 40}
                    },
                    {
                        "label": "名称",
                        "value": "title"
                    },
                    {
                        "label" : "报警",
                        "value" : "alarm",
                        "col"   : {"width": 40},
                        "format": function (item, td) {
                            if (item.alarm) {
                                td.addClass("alarm");
                            }
                        }
                    },
                    {
                        "label" : "在线",
                        "value" : "sta",
                        "col"   : {"width": 40},
                        "format": function (item, td) {
                            if (item.sta === "offline") {
                                td.addClass("onlineSta offline");
                            } else {
                                td.addClass("onlineSta online");
                            }
                        }
                    }
                ],
                "items" : _this.app.modules.WMS.modules.workAreaCameraModule.cameras,
                "format": function (item, tr) {
                    tr.on("click", function () {
                        item.open();
                        item.layer.active();
                        // tr.toggleClass("active", item.isOpened);
                        // if (item.isOpened) {
                        //     item.active();
                        // }
                    });
                }
            };
        });

        _this.app.modules.bridgeDetection.loadInit(function () {

            _this.panels.bridgeDetectionPanel.data = {
                "head"  : [
                    {
                        "label"    : "编号",
                        "autoCount": function (index) {
                            return String(index + 1000).substring(1, 4);
                        },
                        "col"      : {"width": 40}
                    },
                    {
                        "label": "名称",
                        "value": "title"
                    },
                    {
                        "label": "位置",
                        "value": "stakeNum.str",
                        "col"  : {"width": 80}
                    },
                    {
                        "label" : "报警",
                        "value" : "alarm",
                        "col"   : {"width": 40},
                        "format": function (item, td) {
                            if (item.alarm) {
                                td.addClass("alarm");
                            }
                        }
                    },
                    {
                        "label" : "在线",
                        "value" : "sta",
                        "col"   : {"width": 40},
                        "format": function (item, td) {
                            if (item.sta === "offline") {
                                td.addClass("onlineSta offline");
                            } else {
                                td.addClass("onlineSta online");
                            }
                        }
                    }
                ],
                "items" : _this.app.modules.bridgeDetection.items,
                "format": function (item, tr) {

                    item.on("openNode", function () {

                        if (_this.app.activeModule === _this) {
                            _this.closeAllPanels();
                        }

                    });
                    item.on("closeNode", function () {

                        if (_this.app.activeModule === _this) {
                            _this.openAllPanels();
                        }

                    });

                    tr.on("click", function () {
                        item.open();
                        item.layer.active();

                    });
                }
            };
        });

        _this.app.modules.bridgeWeatherDetection.loadInit(function () {

            var currentBridgeWeatherDetection = _this.app.modules.bridgeWeatherDetection.items[0];

            var currentBridgeWeatherDetectionAlarms = [];
            var totalBridgeWeatherDetectionNodeSize = 0;
            var currentBridgeWeatherDetectionNodeSize = 0;

            currentBridgeWeatherDetection.loadNode(function () {

                //自定义报警
                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem.hide();

                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem2 = new CountItem({
                    "title": "报警数量",
                    "count": 0,
                    "unit" : "条",
                    "icon" : _this.app.icons.alarm.base64
                });

                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem2.on("active", function () {
                    _this.panels.bridgeWeatherDetectionPanel.block.ui.table.hide();
                    _this.panels.bridgeWeatherDetectionPanel.block.alarmTable.ui.table.show();
                });

                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem2.on("unActive", function () {
                    _this.panels.bridgeWeatherDetectionPanel.block.ui.table.show();
                    _this.panels.bridgeWeatherDetectionPanel.block.alarmTable.ui.table.hide();
                });

                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem2.on("click", function (item) {
                    item.active(!item.isActive);
                });

                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem.dom.after(
                    _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem2.dom
                );

                _this.panels.bridgeWeatherDetectionPanel.block.alarmTable = new TableBlock();

                _this.panels.bridgeWeatherDetectionPanel.block.alarmTable.head = [
                    {
                        "label"    : "编号",
                        "autoCount": function (index) {
                            return String(index + 1000).substring(1, 4);
                        },
                        "col"      : {"width": 40}
                    },
                    {
                        "label": "监测点名称",
                        "value": "title"
                    },
                    {
                        "label": "报警名称",
                        "value": "alarmSubType"
                    },
                    {
                        "label": "报警时间",
                        "value": "time"
                    }
                ];

                _this.panels.bridgeWeatherDetectionPanel.block.ui.wrap.append(
                    _this.panels.bridgeWeatherDetectionPanel.block.alarmTable.ui.table
                );

                _this.panels.bridgeWeatherDetectionPanel.block.alarmTable.ui.table.hide();

                $.each(currentBridgeWeatherDetection.nodes, function (i, node) {
                    totalBridgeWeatherDetectionNodeSize++;
                });

                $.each(currentBridgeWeatherDetection.nodes, function (i, node) {

                    node.loadThresholdAlert(null, null, function () {

                        currentBridgeWeatherDetectionNodeSize++;

                        // {
                        //     "timestamp": "2025-01-05T09:06:26.558624696",
                        //     "alarmType": "status",
                        //     "alarmSubType": "设备状态",
                        //     "alarmStatus": "其他警告"
                        // }

                        $.each(node.thresholdAlerts, function (i, alarm) {
                            if (alarm.alarmStatus !== "正常") {
                                currentBridgeWeatherDetectionAlarms.push(alarm);
                            }
                        });

                        if (currentBridgeWeatherDetectionNodeSize === totalBridgeWeatherDetectionNodeSize) {

                            //倒排

                            currentBridgeWeatherDetectionAlarms.sort(function (a, b) {
                                return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
                            });

                            //输出表格

                            $.each(currentBridgeWeatherDetectionAlarms, function (i, alarm) {

                                var tr = _this.panels.bridgeWeatherDetectionPanel.block.alarmTable.add({
                                    "title"       : node.title,
                                    "alarmSubType": alarm.alarmSubType,
                                    "time"        : new Date(alarm.timestamp).format("yyyy-MM-dd hh:mm")
                                }, function (item, tr) {
                                    tr.addClass("error");
                                });

                                _this.panels.bridgeWeatherDetectionPanel.block.countItems.alarmItem2.count++;

                                tr.alarmBlock = new BridgeWeatherDetectionNodeAlarmBlock();

                                tr.on("click", function () {

                                    node.open();

                                    _this.app.pop.target = node;
                                    _this.app.pop.position = node.position;

                                    if (tr.alarmBlock.properties === undefined) {
                                        tr.alarmBlock.properties = {
                                            "nodeName"    : node.title,
                                            "alarmType"   : alarm.alarmType,
                                            "alarmSubType": alarm.alarmSubType,
                                            "alarmValue"  : alarm.alarmValue,
                                            "alarmUnit"   : alarm.alarmUnit,
                                            "time"        : new Date(alarm.timestamp).format("yyyy-MM-dd hh:mm")
                                        };
                                    }

                                    _this.app.pop.content = tr.alarmBlock;
                                    _this.app.pop.open();

                                    _this.app.flyItems([node]);
                                });
                            });

                        }


                    });

                });


                //自定义报警结束

                _this.panels.bridgeWeatherDetectionPanel.data = {
                    "head"  : [
                        {
                            "label"    : "编号",
                            "autoCount": function (index) {
                                return String(index + 1000).substring(1, 4);
                            },
                            "col"      : {"width": 40}
                        },
                        {
                            "label": "名称",
                            "value": "title"
                        },
                        {
                            "label": "位置",
                            "value": "bridgeWeatherDetection.stakeNum.str",
                            "col"  : {"width": 80}
                        },
                        {
                            "label" : "报警",
                            "value" : "alarm",
                            "col"   : {"width": 40},
                            "format": function (item, td) {
                                if (item.alarm) {
                                    td.addClass("alarm");
                                }
                            }
                        },
                        {
                            "label" : "在线",
                            "value" : "sta",
                            "col"   : {"width": 40},
                            "format": function (item, td) {
                                if (item.sta === "offline") {
                                    td.addClass("onlineSta offline");
                                } else {
                                    td.addClass("onlineSta online");
                                }
                            }
                        }
                    ],
                    "items" : currentBridgeWeatherDetection.nodes,
                    "format": function (item, tr) {

                        _this.app.modules.bridgeWeatherDetection.on("openNode", function () {

                            if (_this.app.activeModule === _this) {
                                _this.closeAllPanels();
                            }

                        });

                        _this.app.modules.bridgeWeatherDetection.on("closeNode", function () {

                            if (_this.app.activeModule === _this) {
                                _this.openAllPanels();
                                currentBridgeWeatherDetection.layer.close();
                            }

                        });

                        tr.on("click", function () {

                            _this.app.modules.bridgeWeatherDetection.openNode(currentBridgeWeatherDetection);
                            // currentBridgeWeatherDetection.open();

                            // currentBridgeWeatherDetection.openNode();
                            // currentBridgeWeatherDetection.layer.active();
                        });
                    }
                };

            });


        });


        // _this.app.modules.cameraBridge.loadInit(function () {
        //
        //     _this.panels.bridgeEventPanel.data = {
        //         "head"  : [
        //             {
        //                 "label"    : "编号",
        //                 "autoCount": function (index) {
        //                     return String(index + 1000).substring(1, 4);
        //                 },
        //                 "col"      : {"width": 40}
        //             },
        //             {
        //                 "label": "所属桥梁",
        //                 "value": "所属桥梁",
        //                 "col"  : {"width": 155}
        //             },
        //             {
        //                 "label": "名称",
        //                 "value": "title"
        //             },
        //             {
        //                 "label": "状态",
        //                 "value": "sta",
        //                 "col"  : {"width": 40}
        //             }
        //         ],
        //         "items" : _this.app.modules.cameraBridge.items.filter(
        //             function (item, index, arr) {
        //                 return item["所属桥梁"].search("超高预警") < 0;
        //             }
        //         ),
        //         "format": function (item, tr) {
        //             tr.on("click", function () {
        //                 item.open();
        //                 item.layer.active();
        //             });
        //         }
        //     };
        // });

        _this.app.modules.cameraBridge.loadInit(function () {

            // console.log(_this.app.modules.cameraBridge.items);

            _this.app.modules.eventAlert.loadInit(function () {


                $.each(_this.app.modules.cameraBridge.items, function (i, camera) {

                    $.each(_this.app.modules.eventAlert.items, function (i, eventAlertCamera) {

                        if (eventAlertCamera.channelName === camera.title) {
                            camera.eventAlert = eventAlertCamera.events[0];
                            camera.alarm = true;
                            return false;
                        }

                    });

                });


                // _this.panels.bridgeEventPanel.data = {
                //     "head"  : [
                //         {
                //             "label"    : "编号",
                //             "autoCount": function (index) {
                //                 return String(index + 1000).substring(1, 4);
                //             },
                //             "col"      : {"width": 40}
                //         },
                //         {
                //             "label": "摄像头",
                //             "value": "deviceName",
                //             "col"  : {"width": 155}
                //         },
                //         {
                //             "label": "告警事件",
                //             "value": "title"
                //         },
                //         {
                //             "label": "状态",
                //             "value": "sta",
                //             "col"  : {"width": 40}
                //         }
                //     ],
                //     "items" : (
                //         function () {
                //
                //             var eventAlerts = [];
                //
                //             $.each(_this.app.modules.eventAlert.listPanel.listBlock.list, function (i, listItem) {
                //
                //                 listItem.eventAlert.alarm = (listItem.eventAlert.alarmStatus === "1");
                //                 eventAlerts.push(listItem.eventAlert);
                //
                //             });
                //
                //             // console.log(eventAlerts);
                //
                //             return eventAlerts;
                //
                //         }()
                //     ),
                //     "format": function (item, tr) {
                //         tr.on("click", function () {
                //
                //             item.listItem.trigger("click");
                //
                //             // item.camera && item.camera.active();
                //             // item.camera && item.camera.layer && item.camera.layer.active();
                //
                //         });
                //     }
                // };

                _this.panels.bridgeEventPanel.data = {
                    "head"  : [
                        {
                            "label"    : "编号",
                            "autoCount": function (index) {
                                return String(index + 1000).substring(1, 4);
                            },
                            "col"      : {"width": 40}
                        },
                        {
                            "label": "名称",
                            "value": "title"
                        },
                        {
                            "label" : "报警",
                            "value" : "alarm",
                            "col"   : {"width": 40},
                            "format": function (item, td) {
                                if (item.alarm) {
                                    td.addClass("alarm");
                                }
                            }
                        },
                        {
                            "label" : "在线",
                            "value" : "sta",
                            "col"   : {"width": 40},
                            "format": function (item, td) {
                                if (item.sta === "offline") {
                                    td.addClass("onlineSta offline");
                                } else {
                                    td.addClass("onlineSta online");
                                }
                            }
                        }
                    ],
                    "items" : _this.app.modules.cameraBridge.items.filter(
                        function (item, index, arr) {
                            return (item["所属桥梁"].search("超高预警") < 0 && item["所属桥梁"].search("智慧仓储") < 0);
                        }
                    ),
                    "format": function (item, tr) {
                        tr.on("click", function () {
                            item.open();
                            item.layer.active();

                            if (item.alarm) {

                                if (item.eventAlert.camera && item.eventAlert.camera.position) {
                                    item.eventAlert.block.load();
                                    _this.app.pop.target = item.eventAlert.camera;
                                    _this.app.pop.content = item.eventAlert.block;
                                    _this.app.pop.position = item.eventAlert.camera.position;
                                    _this.app.pop.open();
                                }
                            }

                        });
                    }
                };

                _this.panels.ETCPanel.data = {
                    "head"  : [
                        {
                            "label"    : "编号",
                            "autoCount": function (index) {
                                return String(index + 1000).substring(1, 4);
                            },
                            "col"      : {"width": 40}
                        },
                        {
                            "label": "名称",
                            "value": "title"
                        },
                        {
                            "label" : "报警",
                            "value" : "alarm",
                            "col"   : {"width": 40},
                            "format": function (item, td) {
                                if (item.alarm) {
                                    td.addClass("alarm");
                                }
                            }
                        },
                        {
                            "label" : "在线",
                            "value" : "sta",
                            "col"   : {"width": 40},
                            "format": function (item, td) {
                                if (item.sta === "offline") {
                                    td.addClass("onlineSta offline");
                                } else {
                                    td.addClass("onlineSta online");
                                }
                            }
                        }
                    ],
                    "items" : _this.app.modules.cameraBridge.items.filter(
                        function (item, index, arr) {
                            return item["所属桥梁"].search("超高预警") >= 0;
                        }
                    ),
                    "format": function (item, tr) {
                        tr.on("click", function () {
                            item.open();
                            item.layer.active();

                            if (item.alarm) {

                                if (item.eventAlert.camera && item.eventAlert.camera.position) {
                                    item.eventAlert.block.load();
                                    _this.app.pop.target = item.eventAlert.camera;
                                    _this.app.pop.content = item.eventAlert.block;
                                    _this.app.pop.position = item.eventAlert.camera.position;
                                    _this.app.pop.open();
                                }
                            }

                        });
                    }
                };

            });


        });

        // _this.app.modules.road.weatherGeterModule.loadInit(function () {
        //
        //     _this.panels.weatherPanel.data = {
        //         "head"  : [
        //             {
        //                 "label"    : "编号",
        //                 "autoCount": function (index) {
        //                     return String(index + 1000).substring(1, 4);
        //                 },
        //                 "col"      : {"width": 40}
        //             },
        //             {
        //                 "label": "名称",
        //                 "value": "名称"
        //             },
        //             {
        //                 "label": "位置",
        //                 "value": "stakeNum.str",
        //                 "col"  : {"width": 80}
        //             },
        //             {
        //                 "label" : "报警",
        //                 "value" : "alarm",
        //                 "col"   : {"width": 40},
        //                 "format": function (item, td) {
        //                     if (item.alarm) {
        //                         td.addClass("alarm");
        //                     }
        //                 }
        //             },
        //             {
        //                 "label" : "在线",
        //                 "value" : "sta",
        //                 "col"   : {"width": 40},
        //                 "format": function (item, td) {
        //                     if (item.sta === "offline") {
        //                         td.addClass("onlineSta offline");
        //                     } else {
        //                         td.addClass("onlineSta online");
        //                     }
        //                 }
        //             }
        //         ],
        //         "items" : _this.app.modules.road.weatherGeterModule.items,
        //         "format": function (item, tr) {
        //             tr.on("click", function () {
        //                 item.open();
        //                 item.layer.active();
        //             });
        //         }
        //     };
        // });

        _this.app.modules.camera.loadInit(function () {

            _this.panels.roadCameraPanel.data = {
                "head"  : [
                    {
                        "label"    : "编号",
                        "autoCount": function (index) {
                            return String(index + 1000).substring(1, 4);
                        },
                        "col"      : {"width": 40}
                    },
                    {
                        "label": "名称",
                        "value": "title"
                    },
                    {
                        "label" : "报警",
                        "value" : "alarm",
                        "col"   : {"width": 40},
                        "format": function (item, td) {
                            if (item.alarm) {
                                td.addClass("alarm");
                            }
                        }
                    },
                    {
                        "label" : "在线",
                        "value" : "sta",
                        "col"   : {"width": 40},
                        "format": function (item, td) {
                            if (item.sta === "offline") {
                                td.addClass("onlineSta offline");
                            } else {
                                td.addClass("onlineSta online");
                            }
                        }
                    }
                ],
                "items" : _this.app.modules.camera.items,
                "format": function (item, tr) {
                    tr.on("click", function () {
                        item.open();
                        item.layer.active();
                    });
                }
            };
        });


        new mhjs.Request({
            "method": "get",
            "url"   : "./data/restTPL/ROAD/geojson/cline.geojson"
        }).send({}, function (json) {

            var positions = new uMap.Positions(json.features[0].geometry.coordinates);

            _this.areaLayer = new Layer({
                "app": _this.app
            });

            _this.layer.addLayer(_this.areaLayer);

            _this.areaLayer.dataSources.entities.add(
                new uMap.Entity({
                    objectOption: {
                        position: {
                            "longitude": 120.62020693201853, "latitude": 31.035725014344894
                        },
                        polyline: new uMap.PolylineGraphic({
                            objectOption: {
                                positions    : positions.positions,
                                clampToGround: true,
                                width        : 2,
                                color        : ["#0f0"]
                                // , level      : [1e3]
                            }
                        }),
                        label   : new uMap.LabelGraphic({
                            objectOption: {
                                text          : "G50沪渝高速江苏段"
                                , font        : "18px Microsoft Yahei"
                                , fillColor   : ["#fff"]
                                , outlineColor: ["#000"]
                                , outlineWidth: 5.0
                                // , level      : [1e3]
                                , disableDepthTestDistance: Number.POSITIVE_INFINITY
                            }
                        })
                    }
                }).object);

            _this.areaLayer.open();

        });

        new mhjs.Request({
            "method": "get",
            "url"   : "./data/restTPL/ROAD/geojson/workarea.geojson"
        }).send({}, function (json) {

            var positions = new uMap.Positions(json.features[0].geometry.coordinates[0].concat([json.features[0].geometry.coordinates[0][0]]));

            _this.workAreaLayer = new Layer({
                "app": _this.app
            });

            _this.layer.addLayer(_this.workAreaLayer);

            _this.workAreaLayer.dataSources.entities.add(
                new uMap.Entity({
                    objectOption: {
                        position: {
                            "longitude": 120.72477864112622, "latitude": 31.045911888009066, "height": 12.99912163762359
                        },
                        polyline: new uMap.PolylineGraphic({
                            objectOption: {
                                positions    : positions.positions,
                                clampToGround: true,
                                width        : 2,
                                color        : ["#0f0"]
                                // , level      : [1e3]
                            }
                        }),
                        label   : new uMap.LabelGraphic({
                            objectOption: {
                                text          : "黎里养护工区"
                                , font        : "16px Microsoft Yahei"
                                , fillColor   : ["#fff"]
                                , outlineColor: ["#000"]
                                , outlineWidth: 5.0
                                // , level      : [1e3]
                                , disableDepthTestDistance: Number.POSITIVE_INFINITY
                            }
                        })
                    }
                }).object);

            _this.workAreaLayer.open();

        });

    }

    var _class = DataManageModule;

    mhjs.Inherit(_class, Module);

    Object.defineProperties(_class.prototype, {
        "open"          : {
            value: function () {
                var _this = this;
                _this.app.flyHome(true);
                _this.layer.open();
                _this.openAllPanels();

                _this.isOpened = true;
                _this.trigger("open");
            }
        },
        "close"         : {
            value: function () {
                var _this = this;
                _this.layer.close();
                _this.closeAllPanels();

                _this.isOpened = false;
                _this.trigger("close");
            }
        },
        "toggle"        : {
            value: function () {
                var _this = this;
                if (_this.isOpened) {
                    _this.close();
                } else {
                    _this.open();
                }
            }
        },
        "openAllPanels" : {
            value: function () {
                var _this = this;
                $.each(_this.panels, function (i, panel) {
                    panel.open();
                });
            }
        },
        "closeAllPanels": {
            value: function () {
                var _this = this;
                $.each(_this.panels, function (i, panel) {
                    panel.close();
                });
            }
        }
    });

    return _class;

});